package com.hliushi.netty.server.handler;

import com.hliushi.netty.message.PingMessage;
import com.hliushi.netty.server.session.Session;
import com.hliushi.netty.server.session.SessionFactory;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;

/**
 * @author llhuang10
 * @date 2021/10/22 14:25
 */
@Slf4j
@ChannelHandler.Sharable
public class PingMessageHandler extends SimpleChannelInboundHandler<PingMessage> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, PingMessage msg) throws Exception {
        Session session = SessionFactory.getSession();
        log.debug("获取到 {} 的心跳", session.getUsername(ctx.channel()));
    }
}
